<?php 
/**
* @author Oliver Leisalu, Inditel Meedia
* @package DomFg
* @subpackage Input
*/
class DomFgRange extends DomFgInput {
	
	protected $value1;
	
	protected $value2;
	
	protected $textMiddle;
	
	public function __construct( $name = NULL, $value1 = NULL, $value2 = NULL ) {
		parent::__construct( $name );
		$this->value1( $value1 );
		$this->value2( $value2 );
	}
	
	public function value1( $value ) {
		$this->value1 = (float)$value;
		return $this;
	}
	
	public function value2( $value ) {
		$this->value2 = (float)$value;
		return $this;
	}
	
	public function textMiddle( $textMiddle ) {
		$this->textMiddle = $textMiddle;
		return $this;
	}
	
	protected static function getReturnValue( $value ) {
		if( is_array($value) && !is_string($value[0]) ) {
			foreach( $value as &$v) {
				$v = self::getReturnValue( $v );
			}
			return $value;
		} else {
			return array((float)$value[0], (float)$value[1]);
		}
	}
	
	public static function parsePost( $name, &$value ) {
		return self::getReturnValue($value);
	}
	
	
	public function render() {
		$renderer = $this->getRenderer();
		$renderer->assign('input', $this );
		return $renderer->fetch('Input/Range.html');
	}
	

}
?>